<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    #dv1{
        width:500px;
        height:500px;
        background:red;
    }
    #dv2{
        width:300px;
        height:300px;
        background:blue;
    }
    #dv3{
        width:100px;
        height:100px;
        background:blueviolet;
    }
</style>
<body>
    <div id="dv1">
        <div id="dv2">
          <div id="dv3">click</div>
        </div>
    </div>
    <script>
        var div1 = document.getElementById("dv1")
        var div2 = document.getElementById("dv2")
        var div3 = document.getElementById("dv3")
        div1.onclick = function(){
            console.log(this.id)
        }
        div2.onclick = function(e){
          
            console.log(this.id)
            // e.stopPropagation();
        }
        div3.onclick = function(e){
            console.log(this.id)
            // e.stopPropagation();
            // window.event.cancelBubble = true
        }
        // 事件冒泡是从元素的最内层开始发生，一直向上传播。
    </script>
</body>
</html>